package problemSpace;

import java.util.ArrayList;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "ConcretePlanning")
public class ConcretePlanning {
	@XmlElementWrapper(name = "Orders")
	@XmlElement(name = "Order")
	public ArrayList<Order> orders;
	@XmlElementWrapper(name = "Vehicles")
	@XmlElement(name = "Vehicle")
	public ArrayList<Vehicle> vehicles;
	@XmlElementWrapper(name = "Stations")
	@XmlElement(name = "Station")
	public ArrayList<Station> stations;
	@XmlElement(name = "Output")
	public Output output;

	public ConcretePlanning() {
		orders = new ArrayList<Order>();
		vehicles = new ArrayList<Vehicle>();
		stations = new ArrayList<Station>();
		output = new Output();
	}

	/**
	 * Copy constructor
	 */
	public ConcretePlanning(ConcretePlanning s) {
		orders = new ArrayList<Order>();
		vehicles = new ArrayList<Vehicle>();
		stations = new ArrayList<Station>();

		for( Vehicle veh : s.vehicles)
			vehicles.add(new Vehicle(veh));
		for(Order order : s.orders)
			orders.add(new Order(order));
		for(Station station : s.stations)
			stations.add(new Station(station));
		output = new Output();
		output.resultList = new ArrayList<Result>();

		for (Result r : s.output.resultList) {
			Result newr = new Result();
			newr.deliveries = new ArrayList<Delivery>();
			for (Delivery d : r.deliveries) {
				newr.deliveries.add(new Delivery(d));
			}
			output.resultList.add(newr);
		}
	}
	public Order getOrderByCode(String oCode){
		for(Order o : orders){
			if(o.orderCode.equals(oCode))
				return o;
		}
		return null;
		
	}
}
